package com.lecture.springlecture.controller;

import cn.hutool.extra.spring.SpringUtil;
import com.lecture.springlecture.dao.ClassesMapper;
import com.lecture.springlecture.entity.Classes;
import com.lecture.springlecture.service.ClassesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2020/8/6 10:44
 */
@RestController
public class ClassesController {

    private final static Logger logger = LoggerFactory.getLogger(ClassesController.class);

    @Autowired
    private ClassesService classesService;

    @GetMapping("getClassesList")
    public List<Classes> getClassesList() {
        List<Classes> classesList = classesService.getClassesList();
        classesList.forEach(classes -> {
            System.out.println(classes.getStudentList().size());
        });
        return classesList;
    }

    @GetMapping("listClasses")
    public List<Classes> listClasses(String parameter) {
        return classesService.listClasses(parameter);
    }

    @GetMapping("test")
    public void test() {
        logger.info("info输出日志");
        logger.error("error输出日志");
        logger.debug("debug输出日志");
        ClassesMapper classesMapper = SpringUtil.getBean("classesMapper", ClassesMapper.class);
        System.out.println(classesMapper.getClass());
    }
}
